import '../helper/dioHelper.dart';

class StationCheck {
  int ID;
  String StationGuid;
  String UserId;
  String CreateTime;
  int StationID;
  String StationName;
  String WaiGuan;
  String DianYa;
  String WeiXing;
  String DuanXin;
  String Rain1;
  String Rain2;
  String Problems;
  String Works;
  String CEquips;
  String UnDos;
  String CMembers;
  String Remark;
  String RecordQM;
  String ExamQM;

  StationCheck(
      this.ID,
      this.StationGuid,
      this.UserId,
      this.CreateTime,
      this.StationID,
      this.StationName,
      this.WaiGuan,
      this.DianYa,
      this.WeiXing,
      this.DuanXin,
      this.Rain1,
      this.Rain2,
      this.Problems,
      this.Works,
      this.CEquips,
      this.UnDos,
      this.CMembers,
      this.Remark,
      this.RecordQM,
      this.ExamQM);
  StationCheck.fromJson(Map<String, dynamic> json)
      : ID = json["ID"],
        StationGuid = json["StationGuid"],
        UserId = json["UserId"],
        CreateTime = json["CreateTime"],
        StationID = json["StationID"],
        StationName = json["StationName"],
        WaiGuan = json["WaiGuan"],
        DianYa = json["DianYa"],
        WeiXing = json["WeiXing"],
        DuanXin = json["DuanXin"],
        Rain1 = json["Rain1"],
        Rain2 = json["Rain2"],
        Problems = json["Problems"],
        Works = json["Works"],
        CEquips = json["CEquips"],
        UnDos = json["UnDos"],
        CMembers = json["CMembers"],
        Remark = json["Remark"],
        RecordQM = json["RecordQM"],
        ExamQM = json["ExamQM"];
  Map<String, dynamic> toJson() => {
        'ID': ID,
        'StationGuid': StationGuid,
        'UserId': UserId,
        'CreateTime': CreateTime,
        'StationID': StationID,
        'StationName': StationName,
        'WaiGuan': WaiGuan,
        'DianYa': DianYa,
        'WeiXing': WeiXing,
        'DuanXin': DuanXin,
        'Rain1': Rain1,
        'Rain2': Rain2,
        'Problems': Problems,
        'Works': Works,
        'CEquips': CEquips,
        'UnDos': UnDos,
        'CMembers': CMembers,
        'Remark': Remark,
        'RecordQM': RecordQM,
        'ExamQM': ExamQM,
      };
  static Future<bool> Add(StationCheck x1) async {
    var response = await DioHelper.Post("/StationCheck/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(StationCheck x1) async {
    var response = await DioHelper.Post("/StationCheck/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(StationCheck x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/StationCheck/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<StationCheck?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/StationCheck/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200)
      return new StationCheck.fromJson(response.data);
    return null;
  }

  static Future<List<StationCheck>> GetList(
      String where, dynamic data, int pageIndex, int pageSize) async {
    var response = await DioHelper.Post("/StationCheck/GetListByWhere", {
      "Where": where,
      "obj": data,
      "PageIndex": pageIndex,
      "PageSize": pageSize,
    });
    var list1 = <StationCheck>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new StationCheck.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<StationCheck>> GetAllList() async {
    var response = await DioHelper.Get("/StationCheck/GetAllList", {});
    var list1 = <StationCheck>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new StationCheck.fromJson(x));
      }
    }
    return list1;
  }
}
